var gdl = gdl || {};

gdl.math = {};
gdl.math.areEqual = function(a,b){
	builder.clear();
	builder.buildLine("(ABS({0}-{1})<EPS)", a, b);
	var t = builder.toString();
	builder.clear();
	return t;
};
functionManager.register("gdl.math.areEqual","returns boolean indicating whether a and b are almost equal",["a","b"]);

gdl.math.isZero = function(a){
	builder.clear();
	builder.buildLine("(ABS({0})<EPS)", a);
	var t = builder.toString();
	builder.clear();
	return t;
};
functionManager.register("gdl.math.isZero","returns boolean indicating whether a is almost equal to zero",["a"]);

gdl.math.calcLength = function(x,y,z){
	builder.clear();
	builder.build("length = SQR({0}*{0}", arguments[0]);
	var count = arguments.length;
	for(var i = 1; i < count; i++){		
		builder.build("+{0}*{0}", arguments[i]);
	}
	builder.buildLine(")");
	var t = builder.toString();
	builder.clear();
	return t;
};
functionManager.register("gdl.math.calcLength","recalculates length of a vector (2, 3 or more dimensions)",["x","y","..."]);